<?php
class db extends PDO{
    
    public function __construct(){
        $dsn='mysql:host=localhost;dbname=coder;charset=UTF8';
        $username='root';
        $password='root';
        parent::__construct($dsn,$username,$password);
        $this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
    }
    public function mselect($sql,$data=array()){
        $stmt=$this->prepare($sql);
        $stmt->execute($data);
        return $stmt->fetchAll();
    }
    public function select($sql,$data=array()){
        $stmt=$this->prepare($sql);
        $stmt->execute($data);
        return $stmt->fetch();
    }
    public function get_field($sql,$data=array()){
        $stmt=$this->prepare($sql);
        $stmt->execute($data);
        return $stmt->fetchColumn();
    }
}